<?php
/**
 * Created by PhpStorm.
 * User: Dick
 * Date: 2016/3/27
 * Time: 23:54
 */

namespace Controller;

use Method\PageData;
use Model\Message;
use Model\User;

class Getmood
{
    public function getmood()
    {
        $userid = $_SESSION['user']->id;
        $obj = "LEFT JOIN user ON mood.whos = user.id LEFT JOIN follow ON user.id = follow.followed WHERE follow.following =";
        $obj .= $userid;
        $page = new PageData('mood', $obj);
        $page->setRecordPrePage(40);
        $page->execute();
        $pagedata = $page->getContext();
        $message = new Message();
        $message->Getmood($userid, $pagedata);
    }

    public function getcount()
    {
        $userid = $_SESSION['user']->id;
        $moodid = intval($_POST['id']);
        Message::count($userid, $moodid);
    }

    public function getpersonalmood()
    {
        $userid = $_SESSION['user']->towho;
        $userid = User::GetIdByUsername($userid);
        $obj = "WHERE whos =";
        $obj .= $userid;
        $page = new PageData('mood', $obj);
        $page->setRecordPrePage(40);
        $page->execute();
        $pagedata = $page->getContext();
        $message = new Message();
        $message->Getpersonalmood($userid, $pagedata);
    }

    public function getpicmood()
    {
        $userid = $_SESSION['user']->towho;
        $userid = User::GetIdByUsername($userid);
        $obj = "LEFT JOIN image ON image.id=mood.image WHERE whos = ";
        $obj .= $userid;
        $obj .= " AND mood.image IS NOT NULL";
        $page = new PageData('mood', $obj);
        $page->setRecordPrePage(40);
        $page->execute();
        $pagedata = $page->getContext();
        $message = new Message();
        $message->GetPicmood($userid, $pagedata);
    }

    public function delmood()
    {
        $username = $_SESSION['user']->username;
    }

}